﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Collector.Device
{
    /**
     * 设备上报事件码
     * 该事件码由设备决定, 该值来自设备定义
     */
    public enum DeviceEvent
    {
        // 上报设备已经成功复位完成
        eDEV_EVENT_RESET = 0xA4,
        // 上报设备气压帧数据
        eDEV_EVENT_AIR_PRESSURE = 0xA5,
        // 上报设备压力过载, 气压或者脉压
        eDEV_EVENT_OVERFLOW = 0xA6,
        // 上报设备在分段采脉阶段的状态
        eDEV_EVENT_REACHED = 0xA7,
        // 上报设备在连续采脉阶段的状态
        eDEV_EVENT_CONTINUOUS = 0xD1
    }

    /**
     * 设备响应主机指令的ACK码
     * 该ACK码由设备决定, 该值来自设备定义
     */
    public enum DeviceRespondCode
    {
        eDEV_ACK_CODE_OK = 0x00,
        eDEV_ACK_CODE_IS_RESETING = 0x04,
        eDEV_ACK_CODE_ALREADY_RESET = 0x0a
    }

    public enum DeviceSegmentRespondCode
    {
        eDEV_SEGMENT_ACK_CODE_COMPLETED = 0x00,
        eDEV_SEGMENT_ACK_CODE_RISING_TIMEOUT = 0x01,
        eDEV_SEGMENT_ACK_CODE_MEASUING_TIMEOUT = 0x02,
        eDEV_SEGMENT_ACK_CODE_HOST_RESET = 0x03
    }

    public enum DeviceContinuousResponseCode
    {
        eREPORT_STATE_RAPID_PHASE_COMPLETED = 0x00,
        eREPORT_STATE_MEASURE_PHASE_COMPLETED,
        eREPORT_STATE_MEASURE_COMPLETED_WITH_TIMEOUT,
        eREPORT_STATE_RAPID_PHASE_TIMEOUT,
        eREPORT_STATE_RAPID_PHASE_COMPLETED_WITHOUT_ACK = 0x04,
        eREPORT_STATE_HOST_RESET,
        eCODE_DEVICE_OVERRIDE = 0xA6
    }

    /**
     * 三部采脉位置
     * 分别是寸、关、尺脉
     */
    public enum BodyPart
    {
        eBODY_PART_CUN,
        eBODY_PART_GUAN,
        eBODY_PART_CHI
    }

    /**
     * 产品型态
     * 表示单部还是三部
     */
    public enum ProductType
    {
        ePRODUCT_TYPE_SINGLE,
        ePRODUCT_TYPE_THREE
    }

    /**
     * 测试手部位置
     * 左手 or 右手
     */
    public enum HandPosition
    {
        eHAND_POS_LEFT,
        eHAND_POS_RIGHT
    }

    public enum CollectorState
    {
        // 采集器空闲
        eCOLLECTOR_STATE_IDLE,
        // 采集器触发设备开始加压
        eCOLLECTOR_STATE_START_TRIGGER,
        // 采集器开始收集有效的数据
        eCOLLECTOR_STATE_CAPTURING,
        // 采集器收集数据完成
        eCOLLECTOR_STATE_CAPTURE_FINISHED,
        // 采集器所有工作流程结束
        eCOLLECTOR_STATE_COMPLETED
    }

    class IDeviceProtocolShape
    {
        static public readonly UInt32 PULSE_FRAME_HEADER = 0x66BB66BB;
        static public readonly UInt32 CONTROL_FRAME_HEADER = 0x5555AAAA;
        static public readonly byte FRAME_FIELD_LENGTH_OFFSET = 0x04;
        static public readonly byte FRAME_FIELD_CMD_OFFSET = 0x05;
        static public readonly byte FRAME_FIELD_PAYLOAD_OFFSET = 0x06;
        static public readonly byte FRAME_FIELD_SNR_TYPE_OFFSET = 0x08;
        static public readonly byte FRAME_FIELD_PULSE_DATA_H = 0x05;
        static public readonly byte FRAME_FIELD_PULSE_DATA_M = 0x06;
        static public readonly byte FRAME_FIELD_PULSE_DATA_L = 0x07;

    }
}
